package com.order.manager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.order.manager.Model.MenuInfo;
import com.order.manager.service.MenuInfoService;
import com.order.manager.mapper.MenuInfoMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 24862
* @description 针对表【menu_info】的数据库操作Service实现
* @createDate 2024-04-08 15:32:15
*/
@Service
public class MenuInfoServiceImpl extends ServiceImpl<MenuInfoMapper, MenuInfo>
    implements MenuInfoService{

    @Resource
    MenuInfoMapper mapper;

    @Override
    public PageInfo<MenuInfo> queryByShop(String shopId, String menuName, int page, int item) {
        PageMethod.startPage(page,item);
        List<MenuInfo> menuInfos = mapper.selectList(new QueryWrapper<MenuInfo>()
                .eq("shop_id", shopId)
                .eq("state",1)
        );
        return new PageInfo<>(menuInfos);
    }

    @Override
    public PageInfo<MenuInfo> queryByName(String menuName, int page, int item) {
        PageMethod.startPage(page,item);
        List<MenuInfo> menuInfos = mapper.selectList(new QueryWrapper<MenuInfo>()
                .like("menu_name", menuName)
                .eq("state",1)
        );
        return new PageInfo<>(menuInfos);
    }

    @Override
    public PageInfo<MenuInfo> ShopQueryByShop(String shopId, String menuName, int page, int item) {
        PageMethod.startPage(page,item);
        List<MenuInfo> menuInfos = mapper.selectList(new QueryWrapper<MenuInfo>()
                .eq("shop_id", shopId)
        );
        return new PageInfo<>(menuInfos);
    }
}




